package com.heima.admin.v1.controller;

import com.heima.admin.service.AdUserService;
import com.heima.common.dtos.ResponseResult;
import com.heima.model.admin.dtos.AdUserDto;
import com.heima.model.admin.dtos.AdUserLoginDTO;
import com.heima.model.admin.dtos.LoginResponseDTO;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * @author Fuqiang
 * @since :2023-03-24
 */
@Slf4j
@RestController
public class LoginController {


    @Autowired
    private AdUserService adUserService;

    @PostMapping("/login/in")
    public ResponseResult<LoginResponseDTO<AdUserDto>> login(@Validated @RequestBody AdUserLoginDTO userLoginDto) {
        return adUserService.login(userLoginDto);
    }

    @GetMapping("/password/{password}")
    public String get(@PathVariable String password) {
        return adUserService.getPassword(password);
    }
}
